/**
 * 两个桶分别有A升和B升，还有一个容量为C的杯子
 * 问最少操作几次使得两个桶水一样
 * 接水倒水不一定要整数，因此一定可行
 * 简单
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using Real = long double;
using llt = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

#ifndef ONLINE_JUDGE
int const SZ = 101;
#else
int const SZ = 110;
#endif

int A, B, C;

int proc(){
	if(A == B) return 0;
	if(A < B) swap(A, B);
    auto cha = A - B;
	if(cha & 1){
        cha >>= 1;
		auto times = cha / C;
		return times + 1;
	}
	cha >>= 1;
	auto times = cha / C;
	if(cha % C) ++times;
	return times;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase; cin >> nofkase;
	while(nofkase--){
        cin >> A >> B >> C;
		cout << proc() << endl;
	}
    return 0;
}